export const staticRoutes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue'),
    meta: { hidden: true },
  },
  {
    path: '/404',
    component: () => import('@/views/error/404.vue'),
    meta: { hidden: true },
  },
  {
    path: '/',
    component: () => import('@/views/frontView/index.vue'),
    redirect: 'search', // 修改为相对路径
    children: [
      {
        path: 'search',
        name: 'Search',
        meta: { title: '搜索' },
        component: () => import('@/views/frontView/search/index.vue'),
      },
      {
        path: 'detail',
        name: 'Detail',
        meta: { title: '详情' },
        component: () => import('@/views/frontView/details/index.vue'),
      },
      {
        path: 'profile',
        name: 'Profile',
        meta: { title: '个人中心' },
        component: () => import('@/views/frontView/profile/index.vue'),
      },
    ],
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404',
    meta: { hidden: true },
  },
];

// 修改layoutRoute配置
export const layoutRoute = {
  path: '/dashboard',
  name: 'layoutRoute',
  redirect: '/dashboard/overview', // 必须指向有效子路由
  component: () => import('@/layouts/index.vue'),
  children: [] // 确保子路由动态添加到这里
};

// 在authRoutes中添加示例路由（根据实际业务需要）
export const authRoutes = [
  {
    path: 'overview',
    name: 'DashboardOverview',
    component: () => import('@/views/dashboard/index/index.vue'),
    meta: { title: '控制台' }
  },
  {
    path: 'dashboard',
    name: 'Dashboard',
    component: () => import('@/views/dashboard/index.vue'),
    meta: {
      title: '控制台',
      icon: 'dashboard',
      affix: true,
      requiresAuth: true,
    },
    children: [
      {
        path: '',
        meta: { title: '控制台', icon: 'dashboard', affix: true, requiresAuth: true },
        component: () => import('@/views/dashboard/index/index.vue'),
      },
      {
        path: 'books',
        name: 'Books',
        meta: { title: '图书管理', icon: 'book' },
        component: () => import('@/views/dashboard/books/index.vue'),
        children: [
          {
            path: 'list',
            name: 'BookList',
            component: () => import('@/views/dashboard/books/list/index.vue'),
            meta: { title: '图书列表' },
          },
          {
            path: 'tags',
            name: 'BookTags',
            component: () => import('@/views/dashboard/books/tags/index.vue'),
            meta: { title: '标签管理' },
          },
        ],
      },
      {
        path: 'borrows',
        name: 'Borrows',
        component: () => import('@/views/dashboard/borrow/index.vue'),
        meta: { title: '借阅管理' },
        children: [
          {
            path: 'list',
            name: 'BorrowList',
            component: () => import('@/views/dashboard/borrow/list/index.vue'),
            meta: { title: '借阅列表' },
          },
        ],
      },
      {
        path: 'system',
        name: 'System',
        meta: { title: '系统管理', icon: 'system' },
        component: () => import('@/views/dashboard/system/index.vue'),
        children: [
          {
            path: 'users',
            name: 'SystemUsers',
            component: () => import('@/views/dashboard/system/user/index.vue'),
            meta: { title: '用户管理' },
          },
          {
            path: 'settings',
            name: 'SystemSettings',
            component: () => import('@/views/dashboard/system/setting/index.vue'),
            meta: { title: '系统设置' },
          },
        ],
      },
    ],
  },
];

layoutRoute.children = [...authRoutes];